<template>
    <div>
        <div v-if="dialogVisible">
            <el-dialog :title="$t('pageTitle.financeLedger')" :visible.sync="dialogVisible" width="500px">
                <el-form :model="formApplyCorrection" :inline="false" class="module_form">
                    <el-form-item :label="$t('common.contractAmount') + ':'" :label-width="formLabelWidth"><!--内部订单号-->
                        {{ dataInfo.contractAmount }}
                    </el-form-item>
                    <el-form-item :label="$t('common.hasRepayAmount') + ':'" :label-width="formLabelWidth"><!--挂账金额-->
                        <el-col :span="8">
                            {{ dataInfo.payedAmount }}
                        </el-col>
                    </el-form-item>
                    <el-form-item :label="$t('finance.ledgerMoney') + ':'" :label-width="formLabelWidth"><!--罚息-->
                        {{ dataInfo.restRepay }}
                    </el-form-item>
                    <el-form-item :label="$t('common.restRepay') + ':'" :label-width="formLabelWidth"><!--内部订单号-->
                        {{ dataInfo.restRepay }}
                    </el-form-item>
                </el-form>
                <div slot="footer" class="dialog-footer">
                    <el-button @click="dialogVisible = false">{{ $t('common.cancel') }}</el-button>
                    <el-button type="primary" @click="submitLedger">{{ $t('common.confirm') }}</el-button>
                </div>
            </el-dialog>
        </div>
    </div>
</template>

<script>
export default {
    data() {
        return {
            formLabelWidth: this.$i18n.locale === 'zhCN' ? '125px' : "250px",
            dialogVisible: false,
            formApplyCorrection: {
                name: '',
                orderId: '',
                restRepay: '',
                correctReason: this.$t('finance.errorOverdueCorrection'),
                remark: '',
                dataInfo:{}
            },
            
        }
    },
    methods: {
        showBalance(row){
            this.dialogVisible = true;
            this.dataInfo = row;
            console.warn(row,this.dataInfo)
        },
        submitLedger() {
            let info = this.dataInfo;
            let params = {
                orderId: info.orderId,
                normalTransferAmount: info.restRepay,//对公转账
                settleChargeAmount: 0,
                remark:''
            };
            this.$api.finance.fianceLedger.doSettleBill(params).then(res => {
                const { status, error } = res;
                if ('1' === status && '00000000' === error) {
                    this.dialogVisible = false;
                    this.$message.success(this.$tc('common.successfulOperation'));
                    this.$emit('ledgerSucc')
                }
            });
        }
    }
}
</script>